package com.navi.loaddata.loadService.impl.Dcdata.array;

import com.navi.loaddata.core.errorLog.ErrorCode;
import com.navi.loaddata.core.etlException.ETLException2;
import com.navi.loaddata.core.mesEntity.SpcDcdata;
import com.navi.loaddata.core.oracleEntity.EtlGlassV;
import com.navi.loaddata.core.oracleEntity.EtlPdsGlassV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author jay
 */
@Service
public class ProcessDcDataServiceIARRAY {

    private static final Logger logger = LoggerFactory.getLogger(ProcessDcDataServiceIARRAY.class);


    public EtlGlassV processDcData(SpcDcdata d) throws Exception {
        EtlGlassV etlGlassV = new EtlGlassV();
        try {
            etlGlassV.setStepId(d.getProcessoperationname());
            etlGlassV.setSubEquipId(d.getUnitname());
            etlGlassV.setGlassId(d.getMaterialname());
            etlGlassV.setGlassEndTime(d.getEventtime());
//            etlGlassV.setGlassStartTime();
            etlGlassV.setProductId(d.getProductspecname());
//            etlGlassV.setProductVersion();
//            etlGlassV.setRouteId(d.getProcessflowname());
            etlGlassV.setLotId(d.getLotname());
            etlGlassV.setEquipId(d.getMachinename());
//            etlGlassV.setRunMode(d.getRunmode());
            if (StringUtils.isEmpty(d.getRecipename())) {
                etlGlassV.setRecipeId(d.getProductspecname());
            } else {
                etlGlassV.setRecipeId(d.getRecipename());
            }
            etlGlassV.setSubEquipId(d.getUnitname());
            etlGlassV.setOperatorId(d.getEventuser());
//            etlGlassV.setCstId();
//            etlGlassV.setTaShift();
//            etlGlassV.setLotType();
            etlGlassV.setOwnerId(d.getOwnercode());
//            etlGlassV.setOwnerType();
            etlGlassV.setMesLinkKry(d.getMeslinkkey());
//            etlGlassV.setProcessTime(d.getProcesstime());
        }catch (Exception e){
            throw new ETLException2(ErrorCode.ERROR_PROCESS_MES2ORA_PDS_GLASS,e);
        }
//        etlGlassV.setTaShift(); todo
        return etlGlassV;
    }

}
